bitkeeper revision 1.7.1.6 (3df08cc8US1aforRcF-D7KIyM9F8Bw)
authorkaf24@labyrinth.cl.cam.ac.uk <kaf24@labyrinth.cl.cam.ac.uk>
Fri, 6 Dec 2002 11:40:56 +0000 (11:40 +0000)
committerkaf24@labyrinth.cl.cam.ac.uk <kaf24@labyrinth.cl.cam.ac.uk>
Fri, 6 Dec 2002 11:40:56 +0000 (11:40 +0000)
traps.c, setup.c, i387.c:
  Fix floating-point ctxt-switch code

BitKeeper/etc/logging_ok
xen-2.4.16/arch/i386/i387.c
xen-2.4.16/arch/i386/setup.c
xen-2.4.16/arch/i386/traps.c

index 825b553426823a9693f2fdc51117099dbdc3b634..24128f27c5244c151155159e65a1cd6041b2d727 100644 (file)
@@ -1,4 +1,5 @@
 akw27@boulderdash.cl.cam.ac.uk
+kaf24@labyrinth.cl.cam.ac.uk
 kaf24@plym.cl.cam.ac.uk
 kaf24@striker.cl.cam.ac.uk
 smh22@boulderdash.cl.cam.ac.uk
index dc94cc1dadf1343e59f98574425be07dc4506039..fe34ff16f513cdab42c0798dd42b3d4707093a25 100644 (file)
@@ -22,20 +22,26 @@ void init_fpu(void)
 
 static inline void __save_init_fpu( struct task_struct *tsk )
 {
-       if ( cpu_has_fxsr ) {
-               asm volatile( "fxsave %0 ; fnclex"
-                             : "=m" (tsk->thread.i387.fxsave) );
-       } else {
-               asm volatile( "fnsave %0 ; fwait"
-                             : "=m" (tsk->thread.i387.fsave) );
-       }
-       tsk->flags &= ~PF_USEDFPU;
+    if ( cpu_has_fxsr ) {
+        asm volatile( "fxsave %0 ; fnclex"
+                      : "=m" (tsk->thread.i387.fxsave) );
+    } else {
+        asm volatile( "fnsave %0 ; fwait"
+                      : "=m" (tsk->thread.i387.fsave) );
+    }
+    tsk->flags &= ~PF_USEDFPU;
 }
 
 void save_init_fpu( struct task_struct *tsk )
 {
-       __save_init_fpu(tsk);
-       stts();
+    /*
+     * The guest OS may have set the 'virtual STTS' flag.
+     * This causes us to set the real flag, so we'll need
+     * to temporarily clear it while saving f-p state.
+     */
+    if ( tsk->flags & PF_GUEST_STTS ) clts();
+    __save_init_fpu(tsk);
+    stts();
 }
 
 void restore_fpu( struct task_struct *tsk )
index f9163148ed741062824cd99535ce27b7f66aaa94..3cb11f6b05b3c23b96faa1b65ed4d2cfe744319f 100644 (file)
@@ -193,6 +193,9 @@ void __init cpu_init(void)
     /* No nested task. */
     __asm__("pushfl ; andl $0xffffbfff,(%esp) ; popfl");
 
+    /* Ensure FPU gets initialised for each domain. */
+    stts();
+
     /* Set up and load the per-CPU TSS and LDT. */
     t->ss0  = __HYPERVISOR_DS;
     t->esp0 = current->thread.esp0;
index e84690ad1ab417cad00e9979a7a0fca08bfe25d9..6fd88f35f48da2ac598c861d14474326a5fbd849 100644 (file)
@@ -362,7 +362,8 @@ asmlinkage void do_nmi(struct pt_regs * regs, long error_code)
 
 asmlinkage void math_state_restore(struct pt_regs *regs, long error_code)
 {
-    __asm__ __volatile__("clts");
+    /* Prevent recursion. */
+    clts();
 
     if ( !(current->flags & PF_USEDFPU) )
     {